package com.zy.imagineCommunity.dao;

import com.zy.imagineCommunity.entity.Blog;
import com.zy.imagineCommunity.entity.BlogText;
import com.zy.imagineCommunity.entity.BlogTextTwo;
import com.zy.imagineCommunity.entity.Praise;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper //mybatis标记注解bean
public interface BlogMapper {

    //增加文章
    public int addBlog(Blog blog);

    //根据类型查询总记录数
    public int queryBlogCountTotalByType(int type);

    //根据类型、起始条数、每页个数查询文章
    public List<BlogText> queryBlogByTypeAndBeginAndPageSize(int type, int begin, int pageSize);

    //根据id查询文章
    public BlogText queryBlogById(int id);

    //查询总记录数
    public int queryBlogCountTotal();

    //后台管理、根据起始条数、每页个数查询文章
    public List<BlogTextTwo> queryBlogBeginAndPageSize(int begin, int pageSize);

    //根据id删除用户id
    public int deleteBlogById(int id);

    //根据id查询个人博客数
    int queryPersonalBlogCountTotalByUseId(int userId);

    //根据id、起始条数、每页个数查询个人文章
    public List<BlogTextTwo> queryPersonalBlogByUseIdAndBeginAndPageSize(int userId, int begin, int pageSize);

    //根据模糊标题查询博客数
    int queryBlogCountTotalByTitle(String title);

    //根据模糊标题、起始条数、每页个数模糊查询文章
    public List<BlogTextTwo> queryBlogByTitleAndBeginAndPageSize(String title, int begin, int pageSize);

    //根据类型、起始条数、每页个数查询文章
    public List<BlogTextTwo> queryBlogTextTwoByTypeAndBeginAndPageSize(int type, int begin, int pageSize);

    //根据UserId和BlogId查询此用户是否对该文章有点赞
    public Praise queryPraiseByBlogIdAndUserId(int blogId, int userId);

    //增加点赞记录
    public void addPraise(Praise praise);

    //删除点赞记录
    public void deletePraise(int blogId, int userId);

    //修改blog
    public int updateBlogById(Blog blog);

    //根据点赞数倒叙、起始条数、每页个数查询文章
    public List<BlogText> queryBlogByPraiseAndBeginAndPageSize(int begin, int pageSize);

    //查询个人博客时用到的blog数量
    int searchPersonalBlogCountTotalByUseIdAndSearchValue(int userId, String searchValue);

    //查询个人博客页
    List<BlogTextTwo> searchPersonalBlogByUseIdAndBeginAndPageSizeAndSearchValue(int userId, int begin, int pageSize, String searchValue);

}
